package com.tao.demo.controller.rivers;

import com.tao.demo.domain.entity.WaterQuality;
import com.tao.demo.domain.vo.*;
import com.tao.demo.service.WaterQualityService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tao.demo.core.controller.BaseController;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 断面水质数据表 前端控制器
 *
 * @author LiTao
 * @since 2024-04-23
 */
@RestController
@RequestMapping("/waterQuality")
public class WaterQualityController extends BaseController<WaterQualityService, WaterQuality> {
  /**
   * 获取指定省份分类水质等级数量
   * @param province 省份
   * @return 省份分类水质等级数量
   */
  @GetMapping("/categoryDistribution/{province}")
  public List<CategoryVO> categoryDistribution(@PathVariable String province){
    List<Map<String, Object>> maps = baseService.waterQualityCategoryDistribution(province);
    return maps.stream().map(CategoryVO::fromEntity).collect(Collectors.toList());
  }
  /**
   * 获取水温变化
   * @return 水温变化
   */
  @GetMapping("/waterTemperatureChange")
  public List<WaterTemperatureVO> waterTemperatureChange(){
    List<Map<String, Object>> maps = baseService.waterTemperatureChange();
    return maps.stream().map(WaterTemperatureVO::fromEntity).collect(Collectors.toList());
  }
  /**
   * ph值
   * @return ph值
   */
  @GetMapping("/phDistribution")
  public List<PhDistributionVO> phDistribution(){
    List<Map<String, Object>> maps = baseService.phDistribution();
    return maps.stream().map(PhDistributionVO::fromEntity).collect(Collectors.toList());
  }
  /**
   * 溶解氧含量与电导率的相关性
   * @return 相关性
   */
  @GetMapping("/relevance")
  public List<RelevanceVO> relevance(){
    List<Map<String, Object>> maps = baseService.relevance();
    return maps.stream().map(RelevanceVO::fromEntity).collect(Collectors.toList());
  }
  /**
   * 浊度分布
   * @return 浊度分布
   */
  @GetMapping("/turbidityDistribution")
  public List<TurbidityVO> turbidityDistribution(){
    List<Map<String, Object>> maps = baseService.turbidityDistribution();
    return maps.stream().map(TurbidityVO::fromEntity).collect(Collectors.toList());
  }

}
